package com.example.collegevice.mapper;


import com.example.pojo.Speciality;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface SpecialityMapper {
    @Insert("insert into speciality(name, college_id) values(#{name}, #{collegeId})")
    void insert(Speciality speciality);

    @Select("select * from speciality where id = #{id}")
    Speciality selectById(Integer id);

    @Select("select speciality.*, college.name as collegeName from speciality left join college on speciality.college_id = college.id")
    List<Speciality> selectAll();

    @Select("select speciality.*, college.name as collegeName from speciality " +
            "left join college on speciality.college_id = college.id " +
            "where speciality.name like concat('%', #{name}, '%')")
    List<Speciality> selectByName(String name);
    @Update("update speciality set name=#{name}, college_id=#{collegeId} where id=#{id}")
    void updateById(Speciality speciality);

    @Delete("delete from speciality where id = #{id}")
    void deleteById(Integer id);


}
